package com.heima.search.controller;

import com.heima.common.dtos.ResponseResult;
import com.heima.model.search.dtos.UserSearchDto;
import com.heima.search.pojo.ArticleDoc;
import com.heima.search.service.ApUserSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Fuqiang
 * @since :2023-03-31
 */
@RestController
public class ApUserSearchController {

    @Autowired
    ApUserSearchService userSearchService;

    /**
     * app用户搜索
     *
     * @param dto
     * @return
     */
    @PostMapping("/api/v1/article/search/search")
    public ResponseResult search(@RequestBody @Validated UserSearchDto dto) {

        List<ArticleDoc> articleDocs = userSearchService.searchByWords(dto);

        return ResponseResult.ok(articleDocs);
    }

}
